import  {userQuery,userDel} from  "../services/userService"
export default {
  namespace: 'userInfo',//name
  state: [],//initState
  reducers: {
    'initList'(state, { payload: list }) {
      return list;
    },
    'delById'(state, { payload: id }) {
      return state.filter(item=>item.id!==id);
    },
  },
  effects: {
    *asyncInitList({ payload }, { call, put }) {  // eslint-disable-line
      //console.log(payload);
      let  res  = yield call(userQuery,payload)
    //  console.log(res);

      yield put({ type: 'initList',payload:res.data });
    },
    *asyncDelById({ payload }, { call, put }) {  // eslint-disable-line
      //console.log(payload);
        yield call(userDel,payload)
    //  console.log(res);

      yield put({ type: 'delById',payload });
    },
  },
};
